package com.fire.common.utils;

import java.io.Serializable;
import java.util.List;

/**
 * 分页工具类
 */
public class PageUtils implements Serializable {
    private static final long serialVersionUID = 1L;
    //总记录数
    private int totalcount;
    //每页记录数
    private int pagesize;
    //总页数
    private int totalpage;
    //当前页数
    private int currpage;
    //列表数据
    private List<?> list;

    /**
     * 分页
     *
     * @param list       列表数据
     * @param totalCount 总记录数
     * @param pageSize   每页记录数
     * @param currPage   当前页数
     */
    public PageUtils(List<?> list, int totalCount, int pageSize, int currPage) {
        this.list = list;
        this.totalcount = totalCount;
        this.pagesize = pageSize;
        this.currpage = currPage;
        this.totalpage = (int) Math.ceil((double) totalCount / pageSize);
    }

    public int getTotalCount() {
        return totalcount;
    }

    public void setTotalCount(int totalCount) {
        this.totalcount = totalCount;
    }

    public int getPageSize() {
        return pagesize;
    }

    public void setPageSize(int pageSize) {
        this.pagesize = pageSize;
    }

    public int getTotalPage() {
        return totalpage;
    }

    public void setTotalPage(int totalPage) {
        this.totalpage = totalPage;
    }

    public int getCurrPage() {
        return currpage;
    }

    public void setCurrPage(int currPage) {
        this.currpage = currPage;
    }

    public List<?> getList() {
        return list;
    }

    public void setList(List<?> list) {
        this.list = list;
    }

}
